package com.zlx.rulemk.demos;

import java.util.LinkedList;
import java.util.List;

/**
 * @author caochen
 */
public class TestMethodTemplate {

    public static void main(String[] args) {
        MyBeanFactory myBeanFactory = new MyBeanFactory();
        myBeanFactory.addProcessor(bean -> System.out.println("这是"));
        myBeanFactory.addProcessor(bean -> System.out.println("解析@Resource"));
        myBeanFactory.getBean();

    }

    static class MyBeanFactory{

        List<BeanPostProcessor> processors = new LinkedList<>();

        public void addProcessor(BeanPostProcessor beanPostProcessor) {
            processors.add(beanPostProcessor);
        }

        public Object getBean() {
            Object bean = new Object();
            for (BeanPostProcessor processor : processors) {
                processor.inject(bean);
            }
            return bean;
        }
    }

    static interface BeanPostProcessor{
        /**
         * 对依赖注入阶段的扩展的
         */
        public void inject(Object bean);
    }


     class BeanPostProcessor1 implements  BeanPostProcessor{

         @Override
         public void inject(Object bean) {

         }
     }


}
